#include "duart.h"
#include "stdio.h"

#include "monitor/monitor.h"

#include "cpu/exceptions.h"
#include "device/device.h"
#include "kutil/kutil.h"
#include "memory/kmalloc.h"
#include "fs/vfs.h"

const char * const g_warmup_message = "\n\n68010 computer system\n"
									  "(c) Stuart Wallace, 2011-2012\n";


void _main()
{
	/* At boot, interrupts are disabled */

	kmeminit();

	/* Install default handlers for all CPU exceptions */
	__cpu_exc_install_default_handlers();

	duart_init();

	kputs(g_warmup_message);

	/* Register drivers and initialise devices */
	kputs("Initialising devices and drivers");
	driver_init();

	printf("%u bytes of heap memory available\n", kfreemem());

	if(vfs_init())
		kputs("VFS failed to initialise");

	/* TODO: set up timer interrupt */
	/* TODO: enable interrupts */

	monitor();
	
	__cpu_halt();		/* should never be reached */
}

